﻿@*@model IEnumerable<Infinity.BusinessLayer.grouptypeViewModel>*@
@model IPagedList<Infinity.BusinessLayer.grouptypeViewModel>
@using PagedList;
@using PagedList.Mvc;

<table>
    <tr>
        <th>
            @*@Html.DisplayNameFor(model => model.GroupTypeID)*@
            GroupType ID
        </th>
        <th>
            @*@Html.DisplayNameFor(model => model.type)*@
            type
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.GroupTypeID)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.type)
        </td>
        <td>
          
            @Html.ActionLink("Edit", "editegrouptype", new { gtID = item.GroupTypeID }, new { @class = "send" })
            <button class="Deletegrouptype" value="@item.GroupTypeID"> Delete</button>
        </td>
    </tr>
     <tr>
        <td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
    </tr>
}

</table>
<table>
    <tr>
        <td>@Html.PagedListPager(Model, page => Url.Action("Index", new { page, searchBy = Request.QueryString["searchBy"], searchfor = Request.QueryString["searchfor"] }))</td>
    </tr>
</table>
<script src="~/Content/js/jquery-1.11.2.min.js"></script>
<script>
    //Delete
    $(document).ready(function () {
    $(".Deletegrouptype").click(function (a) {

        var caller = $(this);
        var id = $(this).val();
        var x = $(this).hasClass('fromedite');

        if (confirm("Are you sure you want to delete")) {
            $.ajax({
                type: "POST",
                url: "/Managerial/GroupType/Deletegrouptype",
                data: { ID: id },
                success: function (list) {
                   
                    if (x == true) {
                        location.href = '/Managerial/GroupType/Index';
                    }
                    else {
                        $('#grouptypeContainer').html(list);
                        alert("deleted Successfully");
                    }
                },
                error: function () {
                   // alert("can't Delet it");
                }
            });
        }
    })
    })
    
</script>



